package com.ivan.oss.controller;

import com.ivan.common.result.Result;
import com.ivan.oss.service.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/*
 * @Author      Ivan
 * @Date        2023/4/6 14:27
 * @Description UserInfoController
 */
@Api(tags = "阿里云oss管理接口")
//@CrossOrigin//使用gateway后做了配置
@RestController
@RequestMapping("/api/oss/file")
public class FileController {

    @Autowired
    private FileService fileService;

    @ApiOperation(value = "上传文件到阿里云oss")
    @PostMapping("/fileUpload")
    public Result fileUpload(MultipartFile file) {
        //获取上传文件
        String url = fileService.fileUpload(file);
        return Result.ok(url);
    }
}
